package com.foreknow.mapping;


import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * 工厂类
 */
public class MappingFactory {
    private static MappingFactory mappingFactory = null;
    //2.创建Map容器
    private Map<String,EntityMapping> maps = new HashMap();
    //1.单例模式
    private MappingFactory() {
    }
    public static MappingFactory getInstance() {
        if (mappingFactory == null) {
            mappingFactory = new MappingFactory();
            //向Map容器中添加通过put(k,v) xxxMapping对象
            mappingFactory.maps.put("ADMIN_MAPPINGIMPL",new AdminMappingImpl());
            mappingFactory.maps.put("GUEST_BOOKIMPL",new GuestbookImpl());
            mappingFactory.maps.put("ABCMAPPINGIMPL",new AbcMappingImpl());
            mappingFactory.maps.put("HELLO_MAPPINGIMPL",new HelloMappingImpl());
        }
        return mappingFactory;
    }

    //3.提供一个方法从Map中根据Key获取对象(xxxMapping)
    public EntityMapping getMap(String key){
//        EntityMapping entityMapping=  maps.get(key);
        return maps.get(key);
    }

}
